package com.shop.admin.dao.admin;


import com.shop.admin.reqeust.admin.AdminActionLogPageReq;
import com.shop.domain.admin.AdminActionLog;
import com.shop.jpa.BaseSQLDao;
import com.shop.jpa.support.QuerySQL;
import com.shop.web.context.WebContext;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Repository;

@Repository
public class AdminActionLogSQLDao extends BaseSQLDao {

    /**
     * 分页查询管理员操作日志列表
     *
     * @param adminActionLogPageReq
     * @return
     */
    public Page<AdminActionLog> page(AdminActionLogPageReq adminActionLogPageReq) {
        String field = "*";
        String from = "t_admin_action_log aal";
        String order = "aal.create_time desc";
        QuerySQL qs = new QuerySQL(WebContext.getPageNo(), WebContext.getPageSize(), field, from, order);
        qs.addWhereWithoutParams("aal.is_deleted = 0");
        qs.addWhereDateGtNotBlank("aal.create_time", adminActionLogPageReq.getBeginCreateDate());
        qs.addWhereDateLtNotBlank("aal.create_time", adminActionLogPageReq.getEndCreateDate());
        qs.addWhereLikeNotBlank("aal.name", adminActionLogPageReq.getName());
        qs.addWhereLikeNotBlank("aal.admin_reality_name", adminActionLogPageReq.getAdminRealityName());
        return this.page(qs, AdminActionLog.class);
    }


}
